/*Copyright (C) 2009 - 2011 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef EXCIT_HEADER
# define EXCIT_HEADER

# define TITRE_EXCIT 			"EXCIT"
# define EXCIT_MAT_X			50
# define EXCIT_MAT_Y			20
# define EXCIT_MAT_ORG_X	(DEFAULT_SCREEN_SIZE_X / 2) - (EXCIT_MAT_X / 2)
# define EXCIT_MAT_ORG_Y	5


/**********************************************************
** Format du fichier de niveau :
**** ' ' : Une case vide
**** '#' : Un mur
**********************************************************/
# define EXCIT_FVIDE    			' '
# define EXCIT_FMUR     			'#'
# define EXCIT_FBORD_DG 			'|'
# define EXCIT_FBORD_HB 			'_'
# define EXCIT_FJOUEUR    		'J'
# define EXCIT_FOBJECTIF			'O'
/* Touches d'édition de l'éditeur de niveau */
# define EXCIT_KEY_EMUR				'm'
# define EXCIT_KEY_EVIDE			'v'
# define EXCIT_KEY_EJOUEUR		'j'
# define EXCIT_KEY_EOBJECTIF	'o'
# define EXCIT_KEY_QUIT 			'0'
/* Couleurs du excit */
# define EXCIT_COL_MUR    		COLOR_WHITE
# define EXCIT_COL_JOUEUR			COLOR_YELLOW
# define EXCIT_COL_OBJECTIF		COLOR_GREEN
/* Carractères affiché du excit */
# define EXCIT_WCH_MUR    		"█"
# define EXCIT_WCH_BORD_DG 		"│"
# define EXCIT_WCH_BORD_HB 		"─"
# define EXCIT_WCH_JOUEUR 		"☺"
# define EXCIT_WCH_OBJECTIF		"◙"

# define EXCIT_LVLS_FILENAME  "niveaux/excit_officiels.lvl"

typedef enum EXCIT_CASE_T {
	EXCIT_VIDE = 0,
	EXCIT_MUR = 1,
	EXCIT_BORD_DG = 2,
	EXCIT_BORD_HB = 4,
	EXCIT_JOUEUR = 8,
	EXCIT_OBJECTIF = 16,
} EXCIT_CASE_T;

typedef struct EXCIT_INF_T {
	IPoint pos_joueur;
	IPoint pos_objectif;
} EXCIT_INF_T;

void excit_menu(void);
void excit_jeu(void);
void excit_affichage_mat(char matrice[1000], char niveau[50], char auteur[100], long temps_ms, int niveau_actuel, int nombre_niveau);
void excit_afficher_infos(void);
void excit_menu_level_editor();
void excit_create_level();
void excit_choose_level_pack_to_edit();
void excit_choose_level_to_edit(char *filename);
void excit_init_to_default(EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], EXCIT_INF_T *inf);
void excit_edit_level_info(char *lvl_name, char *author_name, size_t len);
int excit_level_editor(EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], EXCIT_INF_T *inf);
int excit_append_to_lvl_pack(char *lvl_pack_filename, EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], const char *lvl_name, const char *author_name);
int excit_parse_file(char *filename, char level[1000][50], int choix, EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], EXCIT_INF_T *inf);
void excit_save_level(char *level_file, EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], const char *author_name, const char *level_name);
void excit_display_editor(EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], EXCIT_INF_T *inf);
void excit_display_matrix(EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y]);
void excit_refresh_editor_inf(EXCIT_INF_T *inf);
void excit_display_case(EXCIT_CASE_T cel);
void excit_edit_matrix(EXCIT_CASE_T matrix[EXCIT_MAT_X][EXCIT_MAT_Y], int key, IPoint *cursor_pos, EXCIT_INF_T *inf);
void excit_move_cursor(int key, IPoint *cursor_pos);
void excit_refresh_case(IPoint *pos, EXCIT_CASE_T value);
int excit_charger_niveau(long niveau, char *filename, char matrice[1000], char nom_niveau[50], char nom_auteur[100], int *pos_joueur);

#endif
